package com.example.service;

import com.example.entity.Tiaoji;
import com.example.entity.Yuce;
import com.example.mapper.TiaojiRepository;
import com.example.mapper.YuceRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

//@Service
//public class ExamService {
//    @Autowired
//    private YuceRepository yuceRepository;
//    @Autowired
//    private TiaojiRepository tiaojiRepository;
//
//    // 假设只需要专业、分数、数学类型和英语类型
//    public String evaluate(String major, int score, String mathType, String englishType) {
//        // 这里添加逻辑来处理评估
//        // 例如：根据专业、分数、数学和英语类型来判断是否合格或者推荐调剂
//
//        // 示例逻辑：
//        // 检查是否有符合条件的调剂机会
//        List<Tiaoji> tiaojis = tiaojiRepository.findByMajorAndMathAndEnglish(major, mathType, englishType);
//        for (Tiaoji tiaoji : tiaojis) {
//            if (score > tiaoji.getLow()) {
//                return "Recommended transfer to: " + tiaoji.getSchool() + " in major " + tiaoji.getMajor();
//            }
//        }
//
//        // 如果没有合适的调剂机会，则返回相应信息
//        return "No suitable adjustment opportunities found.";
//    }
//}
@Service
public class ExamService {
    @Autowired
    private TiaojiRepository tiaojiRepository;

    public String evaluate(String major, int score, String mathType, String englishType) {
        List<Tiaoji> tiaojis = tiaojiRepository.findByMajorAndMathAndEnglish(major, mathType, englishType);
        for (Tiaoji tiaoji : tiaojis) {
            if (score > tiaoji.getLow()) {
                return String.format("可以考虑: %s 的专业： %s 招收 %d 人.",
                        tiaoji.getSchool(), tiaoji.getMajor(), tiaoji.getNum());
            }
        }

        return "No suitable adjustment opportunities found.";
    }
}
